
import { getToken } from './token'
import { api_menus } from '@/api/security'
import { loadRouter } from '@/router'
import store from '@/store'


export const loadMenus = () => {
  return new Promise((resolve, reject) => {
    if (getToken()) {
      api_menus().then(menus => {
        store.dispatch('putUserMenus', menus);
        loadRouter(menus);
        console.log('权限加载完毕');
        resolve(menus);
      });
    }else{
      return Promise.resolve();
    }
  });
}
